#ifndef DATAPACK_H
#define DATAPACK_H
#include <stdint.h>
#include <QList>
#include <QObject>
#include "msgparse.h"

typedef struct PACKAGE
{
    uint8_t head= 0xFE;
    uint8_t type;
    uint16_t len;
    QList<uint8_t> payload;
    uint8_t ckH;
    uint8_t ckL;
}PACKAGE_t;


class DataPack : public QObject
{
    Q_OBJECT
public:
    explicit DataPack(QObject *parent = nullptr);

    void checkSum();
    uint8_t *getArrayData();
    int getArrayDataLen();
    void setDataPack(uint8_t t,uint16_t l,QList<uint8_t> p);


    PACKAGE_t package;

    int dataLen;
    uint16_t packetNum;      // 消息总包数
    uint16_t packetVersion;  // 版本信息
    uint16_t packetIndex;   // 当前消息包数


signals:

public slots:
    void parsingOk(uint8_t t,uint16_t l,QList<uint8_t> p,uint8_t ckh,uint8_t ckl);
};

#endif // DATAPACK_H
